<template>
	<view>
<pagestatus v-if="status.code !=200" :status="status" 
v-on:btnclick="getDetail"
></pagestatus>
	<block v-else>
	<view class="article-content">
	<view class="b p10 title">本地动态内容</view>
<!-- #ifdef MP-WEIXIN -->
<txv-video v-if="thread['vs'] !=''" :vid="thread['vs']" width="100%" height="auto" playerid="txv0" :autoplay="true"  controls=true defn="超清" playBtnPosition="center" showProgress=true>
</txv-video>
<!-- #endif -->
<rich-text :nodes="thread.content"></rich-text>
<block v-if="thread.timglist">
<image v-for="(newsitem,index2) in thread.timglist"  
lazy-load="true" style="width:690upx;"
:src="newsitem" mode="widthFix" 
:data-src="newsitem"
@click="preview" 
:data-url="newsitem"></image>
  </block>
<view class="huise">发布时间：{{thread.timestr}}</view>
	<yad  mode="main"></yad>
	</view>
	<block v-if="moredata.length>0">
	<view class="b p10">文章推荐</view>
	<block v-for="(newsitem,index2) in moredata" :key="index2">
	<mediaItem :newitem="newsitem" opentype="redirect"></mediaItem>
	<yad v-if="index2%6==4" mode="feed"></yad>
	</block>
	</block>
<view class="foot-pd"></view>
<view class="foot"><view class="row"><view class="col b c">
<view :class="'col_'+col"  v-if="thread.url">
<uni-link showUnderLine="false"
:href="thread.url">
URL<view>跳转</view>
</uni-link>
</view>
<view :class="'col_'+col" v-if="thread.sid>0">
<navigator :url="'/pageb/shop/t?id='+thread.sid">
SHOP<view>进店</view>
</navigator>
</view>
<view :class="'col_'+col" v-if="thread.tel">
<view @click="telfun()">
TEL<view>电话</view>
</view>
</view>
<view :class="'col_'+col" @click="lcfun(thread.lc)">MAP<view class="red">{{distance}}KM</view></view>
</view></view></view>
	</block>
	</view>
</template>

<script>
var __self=false;/*this的优化 */
var s = require('../../static/ysv8/chat.js');
var p = {
title: getApp().globalData.ysv8set.title,
id: 0,
img:getApp().globalData.ysv8set.img,
timglist:[]
}
	import mediaItem from '@/components/list_www.vue';
	import yad from '@/components/yad.vue'
	import pagestatus from '@/components/page-status.vue'
export default {
		components: {
			mediaItem,yad,pagestatus
		},
		data() {
return {
col:4,
lc:getApp().globalData.ysv8set.lc,
anz: getApp().globalData.ysv8set.anz,
favbool: !1,
moredata: !1,
thread: false,
imgswt: getApp().globalData.ysv8set.imgswt,
loadingType: "more",
    status:{
        loading:true,
        icon:'content',
        title:'页面加载中...',
        desc:'',
        showBtn:false,
        btnText:'',
        code:199
    },
				}
},onLoad: function(t) {
        if (!t.id) uni.navigateBack({});
        __self = this;
        p.id = t.id;
if (t.lc){
		getApp().globalData.ysv8set.lc=t.lc
		this.lc=getApp().globalData.ysv8set.lc
		}
this.getDetail()
},onShareAppMessage: function() {
        uni.setClipboardData({data:p.title});
        return {
            title: p.title,
            content: p.title,
            path: "/pageb/wyq/t?id=" + p.id,
            imageUrl: p.img
        }
},computed:{
distance(){
if(this.lc==false) return 'NAN'
return getApp().globalData.ysv8set.GetDistance(this.lc,this.thread.lc)
}		 
},methods:{

    copytxt: function() {
        var a = __self.thread.content;
        a = a.replace(/[|]*\n/, "");
        a = a.replace(/<\/?[^>]*>/g, "");
        a = a.replace(/&npsp;/gi, "");
        uni.setClipboardData({
            data: getApp().globalData.ysv8set.title2 + a + "\n"+getApp().globalData.ysv8set.www+'zh/' + p.id + ".html"
        })
    },
   
getDetail: function() {
uni.request({
            url: getApp().globalData.ysv8set.www + "wyq/" + p.id + ".api",
            cloudCache:getApp().globalData.ysv8set.cloudCache,
            data: {},
            success: function(e) {
if ("200" != e.data.code)
return  uni.showModal({
    title: '错误提示',
    content: e.data["info"],
    confirmText: '确定',
    success() {
        uni.navigateBack({
            fail() {
                uni.redirectTo({
                    url: '/pageb/wyq/index'
                });
            }

        });
    }
});
if ("img" in e.data.thread_data && e.data.thread_data.img) {
var r = e.data.thread_data.img.split(",");
var l = 0,
i = 0;
 for (l = r.length; i < l; i++) r[i] = getApp().globalData.ysv8set.imgcdn + r[i].split("@")[0];
p.timglist = r;
e.data.thread_data["timglist"]=p.timglist;

p.img = getApp().globalData.ysv8set.imgcdn + e.data.thread_data.img.split("@")[0]
} else p.timglist = [p.img];
p.title = e.data.thread_data["content"].replace(/(<([^>]+)>)/gi, "").substring(0, 50);
e.data.thread_data["timestr"] = getApp().globalData.ysv8set.timeStamp2String(e.data.thread_data['btime'], !0);
let coli=0
if(e.data.thread_data.sid>0){
	coli++
}
if(e.data.thread_data.tel){
	coli++
}
if(e.data.thread_data.url){
	coli++
}
if(coli==3){
	__self.col=3
}else if(coli==2){
	__self.col=4
}else if(coli==1){
	__self.col=6
}else{
	__self.col=12
}



__self.thread=e.data.thread_data,
__self.moredata=e.data.data,
__self.status={
title:'加载完成',
showBtn:false,
code:200
}
if(getApp().globalData.ysv8set.lc==false && !getApp().globalData.lcbool){
getApp().globalData.lcbool=true;
uni.getLocation({
success: function (res) {
getApp().globalData.ysv8set.lc=getApp().globalData.ysv8set.formatLocation(res.longitude, res.latitude);  
__self.lc=getApp().globalData.ysv8set.lc
uni.showToast({ title: '位置已更新'});
},fail:function(){
uni.redirectTo({
url: '/pagea/lcxz/lcxz?url='+encodeURIComponent('/pageb/wyq/index?id='+p.id)
});
}});
}


            },
fail: function() {
__self.status={
title:'网络错误',
desc:'网络连接错误',
showBtn:true,
btnText:'重新加载',
code:400
 }
            }
        })

    }, preview(z) {
    uni.previewImage({
            current: z.target.dataset.src,
            urls: p.timglist
        })
			
    },telfun:function(){
		   uni.makePhoneCall({
		   phoneNumber: this.thread.tel
		   });
		   },lcfun:function(lc){
	let lca=lc.split(',')
	uni.openLocation({
	latitude: parseFloat(lca[0]),
	longitude: parseFloat(lca[1])	      
	});
	},
}
}
</script>

<style>
@import url("/components/gaoyia-parse/parse.css");
</style>
